package com.wms.controller;

import com.wms.bean.PageBean;
import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.dto.ArrivalDto;
import com.wms.entity.Arrival;
import com.wms.service.ArrivalService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "csy到货单")
@RequestMapping("/api")
public class ArrivalController {

    @Autowired
    ArrivalService arrivalService;
    @PostMapping("/arrival/save")
    @ApiOperation("保存到货单")
    public ResultBean save(@RequestBody Arrival arrival){
        int rs=arrivalService.save(arrival);
        return rs==1? R.success("保存成功"):R.fail("保存失败");
    }
    @ApiOperation("获取到货单列表")
    @PostMapping("/arrival/list")
    public ResultBean getAll(@RequestBody ArrivalDto arrivalDto){
        PageBean pageBean =arrivalService.queryAll(arrivalDto);
        return R.success("到货单列表",pageBean);
    }

    @ApiOperation("获取到货单详情")
    @GetMapping("/arrival/getById")
    public ResultBean getById(@RequestParam int id){
        List<Arrival> list=arrivalService.queryDetailById(id);
        return R.success("到货单明细",list);
    }
    @ApiOperation("根据id删除到货单")
    @DeleteMapping("/arrival/deleteById")
    public ResultBean deleteById(@RequestParam int id){
        int rs=arrivalService.removeById(id);
        return rs==1?R.success("删除成功"):R.fail("删除失败");
    }

}
